var App = require('app');

App.FormsController = Em.ObjectController.extend({
	pushForm: function(form) {
		Vari.CurrFormId = form.get("id");

    	Sckt.start(function() {
    		Sckt.sendMsg(Vari.CurrFormId);
    	});
	},
	viewForm: function(form) {
		Vari.CurrFormId = form.get("id");
		this.transitionToRoute("form.view", form);
	},
	deleteForm: function(form) {
		var me = this;
    	var json = $.toJSON(form);

    	$.ajax({
			type : "DELETE",
			dataType: 'json',
			contentType: 'application/json; charset=utf-8',

			async : false,
			url : Vari.ApiRestV1 + 'forms',
			data : json,

			success : function(json) {
				if (json.success) {
					var ls = me.get("content").without(form);
					me.set("content", ls);
				}
			}
		});
	}
});